import java.util.Scanner;

public class SelsortDemo {
    //要求用户输入一个整数数组，然后使用选择排序算法对数组进行升序排序，并输出排序后的结果。

    public static void main(String[] args) {
        System.out.println("请输入几个数并用空格隔开：");
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine().toString();
        String[] arr1 = str.split(" ");
        int[] arr2 = new int[arr1.length];
        for (int i = 0; i < arr1.length; i++) {
            arr2[i] = Integer.parseInt(arr1[i]);
        }
        int min = 0;
        int temp = 0;
        for (int i = 0; i < arr2.length; i++) {
            min = i;
            for (int j = i + 1; j <= arr2.length - 1; j++) {
                if (arr2[min] > arr2[j]) {
                    min = j;
                }
            }
            if (min != i) {
                temp = arr2[min];
                arr2[min] = arr2[i];
                arr2[i] = temp;
            }
        }

        for (int j = 0; j < arr2.length; j++) {
            System.out.print(arr2[j] + " ");
        }
    }

}
